package pers.mor.tomcat;

import pers.mor.tomcat.classloader.CommonClassLoader;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Bootstrap {

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        CommonClassLoader loader = new CommonClassLoader();
        Thread.currentThread().setContextClassLoader(loader);
        Class<?> aClass = loader.loadClass("pers.mor.tomcat.catalina.Server");
        Constructor<?> constructor = aClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        Object instance = constructor.newInstance();
        Method start = aClass.getDeclaredMethod("start");
        start.setAccessible(true);
        start.invoke(instance);
    }

}
